package com.copa.l344;

import java.util.Arrays;

/**
 * @author copa
 * @createDate 2022-06-29 12:35
 * @function 双指针法（对撞指针）
 */
public class Test1 {

    public void reverseString(char[] s) {
        int left = 0;
        int right = s.length - 1;
        char temp;
        while (left < right) {
            temp = s[left];
            s[left] = s[right];
            s[right] = temp;
            left++;
            right--;
        }
    }

    public static void main(String[] args) {
        char[] s = {'H','a','n','n','a','h'};
        new Test1().reverseString(s);
        System.out.println(Arrays.toString(s));
    }
}
